You are here: Orders > Getting a List of Active Orders

Getting a List of Active Orders

You can request a list of active orders from TWS in three different ways:

Request the Connected Client’s Orders – reqOpenOrders

The reqOpenOrders method lets you request a list of only those active orders that were placed by the currently connected client application. In IBSampleApp, active orders received from TWS appear in the Live Orders grid on the Trading tab:

Request All Orders Submitted from the API – reqAllOpenOrders

The reqAllOpenOrders method lets you request a list of active orders submitted from different client applications from each different client.

This is a good time to revisit the order identifier (next valid id). In the image above, see how clients 1, 2 and 3 successfully placed orders with order ID 1. This shows the order ID sequence is independent from one client to another.

Important: Only the client application that originally placed the order (or an application connected with the exact same client ID) can modify its active orders.

What About Orders Submitted Directly from TWS?

The reqAllOpenOrders request can also be used to request those orders placed manually in TWS. The following image shows an order placed directly in TWS and retrieved from the API client application. Note that both the client and order IDs are set to 0.

Take Control Over Orders Submitted Manually in TWS - reqAutoOpenOrders

Use the reqAutoOpenOrders method to request that TWS allow it to take over those orders submitted manually. Only the client application using 0 as its identifier can do this.

Important: Before the API can take over manually-placed orders, you must invoke the reqAutoOpenOrder method before you enter the order in TWS. Only those orders manually placed after this call will be bound.

To help you distinguish manually-submitted orders from those submitted from the API, TWS can bind them to negative identifiers as seen in the following image, which shows the API Settings in the TWS Configuration window.